import { Ext } from "./ext";

export class ExtRoom extends Ext{
    
    /**
     * 
     * @param {Room} room 
     * @returns {ExtRoom}
     */
    static get(room){
        return super.get(room, ()=>new ExtRoom(room));
    }

    /**
     * @private
     * @param {Room} room 
     */
    constructor(room){
        super();
        this.room = room;
    }

    get spawns(){
        if(this._spawns !== undefined){
            return this._spawns;
        }

        return this._spawns = this.room.find(FIND_MY_SPAWNS, {
            filter(spawn){
                return spawn.isActive();
            }
        });
    }
    canSpawn(){
        return this.spawns.length > 0;
    }
}